package mil.af.amc.adpetracker.web.actions.struts2.equipmentItem;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import mil.af.amc.adpetracker.model.EquipmentItem;
import mil.af.amc.adpetracker.service.EquipmentItemService;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jason Ferguson
 */
@ParentPackage("json-default")
@Namespace("/equipmentItem")
public class EquipmentItemAction extends ActionSupport implements ModelDriven<EquipmentItem>, Preparable {

    @Autowired
    private EquipmentItemService equipmentItemService;

    private EquipmentItem model;

    public EquipmentItem getModel() {
        return model;
    }

    public void prepare() {

    }

    private List<EquipmentItem> equipmentItemList;

    public void prepareExecute() {

        // TODO: Need to get the current ADPE Account and load a list of equipment items for that account here
        equipmentItemList = new ArrayList<EquipmentItem>();

    }

    /**
     * Return a view of the list of equipment items for the account
     *
     * @return
     */
    @Action(value="list",results = {
            @Result(name="success",location = "/WEB-INF/struts2/equipmentItem/list.jsp")
    })
    public String execute() {
        return SUCCESS;
    }

    /**
     * Return the edit view
     *
     * @return
     */
    @Action(value="viewEdit", results = {
            @Result(name="success", location = "/WEB-INF/struts2/equipmentItem/edit.jsp")
    })
    public String viewEdit() {
        return SUCCESS;
    }

    /**
     * Update an EquipmentItem
     *
     * @return
     */
    @Action(value="edit", results = {

    })
    public String edit() {
        throw new UnsupportedOperationException();
    }

    /**
     * Get a list of EquipmentItem objects by the ItemModel and return it as JSON
     *
     * @return
     */
    @Action(value="getByItemModel", results = {
        @Result(name="success", type = "json")
    })
    public String getByItemModel() {
        throw new UnsupportedOperationException();
    }

    /**
     * Return a list of Equipment Items by a Model
     *
     * TODO: Is this even being used?
     *
     * @return
     */
    @Action(value="viewByModel", results = {

    })
    public String viewByModel() {
        throw new UnsupportedOperationException();
    }

    /**
     * Get a particular EquipmentItem by its serial number and return it as JSON
     *
     * @return
     */
    @Action(value="getBySerial", results = {
        @Result(name="success", type="json")
    })
    public String getBySerial() {
        throw new UnsupportedOperationException();
    }

    /**
     * Update the User associated with an EquipmentItem
     *
     * @return
     */
    @Action(value="transfer", results = {

    })
    public String transfer() {
        throw new UnsupportedOperationException();
    }

    /**
     * Update a EquipmentItem's Last Inventoried Date
     * @return
     */
    @Action(value="updateInventoryDate", results = {

    })
    public String updateInventoryDate() {
        throw new UnsupportedOperationException();
    }

    /**
     * Update an EquipmentItem's Location
     *
     * @return
     */
    @Action(value="updateLocation", results = {

    })
    public String updateLocation() {
        throw new UnsupportedOperationException();
    }

    /**
     * Return the view to Import a CSV list of EquipmentItem objects
     *
     * @return
     */
    @Action(value = "viewImport", results = {
            @Result(name="success", location = "/WEB-INF/struts2/equipmentItem/viewImport")
    })
    public String viewImportItems() {
        return SUCCESS;
    }

    /**
     * Import a list of EquipmentItems from a CSV-formatted file
     *
     * @return
     */
    @Action(value="import", results = {

    })
    public String importItems() {
        throw new UnsupportedOperationException();
    }

    /**
     * Return the delete view
     *
     * TODO: I don't think this is being used anywhere
     *
     * @return
     */
    @Action(value="viewDelete", results = {
        @Result(name="success", location = "/WEB-INF/struts2/equipmentItem/viewDelete.jsp")
    })
    public String viewDelete() {
        throw new UnsupportedOperationException();
    }

    /**
     * Delete an EquipmentItem
     *
     * @return
     */
    @Action(value="delete", results = {

    })
    public String delete() {
        throw new UnsupportedOperationException();
    }

    /**
     * Update an EquipmentItem's assigned User to null (item just in a pile somewhere)
     *
     * @return
     */
    @Action(value="unassign", results = {

    })
    public String unassign() {
        throw new UnsupportedOperationException();
    }


}
